package ink.yql.dao;

import ink.yql.model.Orderform;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderformDao {
    /**
     *
     * @param uid 用户id
     * @return  订单集合
     * 查看用户的所有订单
     */
    @Select("select * from orderform where uid = #{uid}")
    List<Orderform> getByUid(@Param("uid") Integer uid);

    /**
     *
     * @param uid 用户id
     * @param status    订单状态
     * @return  订单集合
     * 查看用户某一状态的所有订单
     */
    @Select("select * from orderform where uid = #{uid} and ostatus = #{status} ")
    List<Orderform> getByUidStatus(@Param("uid") Integer uid, @Param("status") Integer status);

    /***
     *
     * @param oid 订单id
     * @return 订单详情
     * 查看订单详情
     */
    @Select("select * from orderform where oid = #{oid}")
    Orderform getByOid(@Param("oid") Integer oid);

    /**
     *
     * @param orderform 订单对象
     * @return  影响行数
     *  添加一个订单
     */
    @Insert("insert into orderform (uid,rid,ostatus,aid,createTime) values (#{uid},#{rid},#{ostatus} ,#{aid} ,#{createTime})")
    Integer addOne(Orderform orderform);

    /**
     *
     * @param orderform 订单对象
     * @return  影响行数
     * 改变付款账号和订单状态
     */
    @Update("update orderform set aid = #{aid} ,ostatus = #{ostatus} where oid= #{oid}")
    Integer update(Orderform orderform);

    /**
     *
     * @param oid 订单id
     * @return  影响行数
     * 删除一个订单记录
     */
    @Delete("delete from orderform where oid = #{oid} ")
    Integer delete(@Param("oid") Integer oid);
}
